<template>
	<view class="bindEntre">
		<!-- <navBar backColor="#000" background="#fff"></navBar> -->
		<nav-bars fontColor="#000" bgColor="#fff"></nav-bars>
		<h2>是否加入该超级管家团队？</h2>
		<view class="entreInfo">
			<image :src="stewardInfo.super_data.headimg.path" mode=""></image>
			{{stewardInfo.stewardName}}
		</view>
		<view class="subBtn">
			<button type="default" @click="toSubmit">确定</button>
		</view>
	</view>
</template>

<script>
	import navBar from '@/components/navBar/navBar.vue'
	import service_distri from '@/service/distri.js'
	import service_enter from '@/service/enter.js'
	import { ApplySteward, StewardInfo } from '@/service/superHK.js'
	export default{
		data(){
			return{
				to_id:null, // 分享过来的分享者userId
				steward_id:null,// 分享过来的管家团队id
				stewardInfo:{}, //超级管家团队信息
			}
		},
		components:{
			navBar
		},
		onLoad(options) {
			// this.$utils.getUrl()
			uni.removeStorageSync('to_id')
			uni.removeStorageSync('to_steward_id')
			let scene= decodeURIComponent(options.scene) //二维码扫码时的参数
			console.log(scene,'二维码参数')
			console.log(options,'转发时参数')
			scene = scene.split("&");
			let obj = {}
			let app = getApp()
			for(let i = 0;i<scene.length;i++){
				let newscene = scene[i].split("=");
				obj[newscene[0]] = newscene[1];
			}
			if(obj.to_id){
				this.to_id = obj.to_id;
				this.steward_id = obj.steward_id;
			}else {
				this.to_id = options.to_id;
				this.steward_id = options.steward_id;
			}
			let token = this.$store.state.index.token
			if(!token){
				uni.setStorageSync('to_id',this.to_id);
				uni.setStorageSync('to_steward_id',this.steward_id);
				uni.redirectTo({
					url:'/pages_login/pages/login/login/index'
				})
			}else{
				this.GetStewardInfo()
			}
		},
		onShow() {},
		methods:{
			// 获取超级管家信息
			async GetStewardInfo(){
				const that = this;
				let params = {
					steward_id:that.steward_id,
					share_id:''
				}
				let res = await StewardInfo(params)
				if(res.code == 1){
					that.stewardInfo = res.data
				}
			},
			
			// 确定按钮
			async toSubmit(){
				const that = this;
				let res = await ApplySteward({to_id:that.to_id})
				if(res.code == 1){
					uni.showToast({
						title:'已提交加入申请',
						icon:'success'
					})
					setTimeout(()=>{
						uni.reLaunch({
							url:'/pages/mall/newIndex/newIndex'
						})
					},500)
				}else{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
				}
			}
		}
	}
</script>

<style lang="scss" >
	page{height: 100%;}
	.bindEntre{
		width: 100%;
		height: 100%;
		background-color: #fff;
		h2{
			width: 100%;
			text-align: center;
			font: 500 40rpx/52rpx PingFang SC;
			margin: 100rpx 0 150rpx 0;
			color: #0A0605;
		}
		.entreInfo{
			margin: 0 auto;
			width: 568rpx;
			// height: 416rpx;
			padding: 100rpx;
			box-shadow:0rpx 0rpx 20rpx 1rpx rgba(0,0,0,0.1);
			display: flex;
			flex-direction: column;
			font: 400 32rpx/80rpx PingFang SC;
			color: #505050;
			border-radius: 10rpx;
			align-items: center;
			justify-content: center;
			image{width: 150rpx;height: 150rpx;border-radius: 50%;background-color: #ccc;}
		}
		.subBtn{
			width: 100%;
			text-align: center;
			position: fixed;
			bottom: 0;
			height: calc(100rpx+ constant(safe-area-inset-bottom));///兼容 IOS<11.2/
			height: calc(100rpx + env(safe-area-inset-bottom));///兼容 IOS>11.2/
			padding-bottom: constant(safe-area-inset-bottom);///兼容 IOS<11.2/
			padding-bottom: env(safe-area-inset-bottom);///兼容 IOS>11.2/
			button{
				// margin-bottom: 10rpx;
				width: 586rpx;
				height: 84rpx;
				background-color: #364052;
				color: #fff;
				font: 500 28rpx/84rpx PingFang SC;
				border-radius: 44rpx;
			}
		}
		
	}
</style>
